<template>
  <!-- 接收签到 -->
  <div>
      <el-empty v-if="isempty" description="该功能正在开发中"></el-empty>
  <div title="点击查看详情" class="receive-box" v-else>
    <div @click="dialogVisible = true">
      <el-main>
        <h2>第一次通知</h2>
        <p>{{ message | ellipsis }}</p>
      </el-main>
      <el-footer>
        <span class="Notic-read" ref="read">{{ flag }}</span>
        <span>{{ publisher }}</span>
        <span>{{ readNum }}阅读量</span>
        <span>{{ outTime }}天前</span>
      </el-footer>
    </div>
    <!-- 删除按键确认 -->
    <el-popconfirm @confirm="pop" title="确定删除吗？" class="del-but">
          <el-button
           class="Notic-del"
            slot="reference"
            type="danger"
            icon="el-icon-delete"
            plain
            circle
          ></el-button>
        </el-popconfirm>
    <!-- 弹窗区域 -->
    <el-dialog
      title="第一次通知"
      :visible.sync="dialogVisible"
      :modal-append-to-body="false"
      v-if="show=true"
      center
      width="60%">
      <span class="span-time">{{noticTimes|dateFmt}}</span>
        <p>{{ message }}</p>
        <span>{{ publisher }}</span>
        <span>{{ readNum }}阅读量</span>
        <span>{{ outTime }}天前</span>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="diaVis">确 定</el-button>
      </div>
    </el-dialog>
  </div>
  </div>

</template>

<script>
import moment from 'moment'
export default {
  name: 'ReceiveSign',
  props: {},
  components: {},
  data () {
    return {
      message:
        '1. 报名未开始前，考生可进行注册及学籍信息验证操作，具体报名时间以各学校通知为准。2. 请在报名完成后24小时内完成缴费，并再次登录系统确认是否报名成功，如有疑问可拨打客服电话进行咨询。3. 9月27日起，参加2021年上半年考试考生可登录中国教育考试网（www.neea.edu.cn），免费查询下载电子成绩报告单（证书），电子成绩报告单（证书）与纸质成绩报告单（证书）同等效力。',
      flag: '未读',
      publisher: '发布人',
      readNum: 88,
      noticTimes: new Date(),
      outTime: 3,
      dialogVisible: false,
      show: false,
      reNotic: true,
      isempty: true
    }
  },
  filters: {
    // 超出一定字数显示省略号的过滤器
    ellipsis (val) {
      if (!val) return ''
      if (val.length > 60) {
        return val.slice(0, 60) + '......'
      }
      return val
    },
    // 格式化时间的过滤器
    dateFmt (value) {
      return moment(value).format('YYYY-MM-DD HH:mm:ss')
    }
  },
  methods: {
    // 删除处理
    pop () {
      this.reFresh = false
      this.$emit("NoitcDel", this.reFresh)
      this.$message({
        type: 'success',
        message: '删除成功'
      })
    },
    // 取消弹窗，并设置已读
    diaVis () {
      this.dialogVisible = false
      this.flag = '已读'
      this.$refs.read.style.color = '#bbb'
      this.show = false
    }
  }
}
</script>

<style lang="less" scoped>
.receive-box {
  position: relative;
  cursor: pointer;
  display: flex;
  background-color: #FFF;
  flex-direction: column;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  margin-bottom: 10px;
  p{
      font-size: 18px;
      letter-spacing: 1px;
    }
  .el-main {
    padding: 10px 20px;
    span {
      margin: 0 50px;
    }
  }
  .el-footer {
    display: flex;
    line-height: 60px;
    margin-left: 70%;
    justify-content: space-between;
    span{
      color: #bbb;
    }
    .Notic-read {
      color: red;
    }
  }
  .Notic-del{
    background-color: #FFF;
    color: #000;
    border: none;
  }
  .Notic-del:hover{
    background-color: #f56c6c;
    color: #fff;
  }
  /deep/.el-dialog__body{
    color: #000;
    font-size: 16px;
    position: relative;
    .span-time{
      background-color: transparent;
      position: absolute;
      right: 0;
      top: 0;
    }
    span{
      margin: 0 10px;
      background-color: #ddd;
      padding: 10px;
      border-radius: 15px;
      float: right;
    }
  }
  .del-but{
    position: absolute;
    bottom: 5%;
    left: 65%;
  }
}
</style>
